<!--
 * @Author: 李瑞清
 * @Date: 2023-02-24 17:28:14
 * @LastEditors: 李瑞清 alger_li@163.com
 * @LastEditTime: 2023-04-10 10:59:56
 * @FilePath: \oms\page\followup\html\dataCenter\dataCenterNew.html
 * @Description:
-->
<!-- author: 汪孟苹 -->
<style>
    @media print {
        @page {
            margin: 0;
        }

        body {
            margin: 1cm;
        }
    }

    .datacenter .age {
        width: 50px;
    }

    .datacenter .footer {
        text-align: right;
        box-sizing: border-box;
        padding-top: 20px;
    }

    .datacenter .queue-btn {
        padding: 0;
    }

    table {
        width: 80%;
    }

    table th {
        width: 20%;
        padding: 5px;
        text-align: center;
    }

    table td {
        width: 20%;
        padding: 5px;
        text-align: center;
    }


</style>

<body>
<div class="datacenter panel panel-default" id="root" style="position: relative">
    <div class="panel-heading" id="roots">
        <h3 class="panel-title" data-language="true" data-language-key="dataCenterAllPatient">全部患者</h3>
    </div>
    <div class="panel-body dataCenter-wrap" id="rootss">
        <div class="form-horizontal">
            <el-form :inline="true" :model="searchForm" class="demo-form-inline">
                <el-form-item label="科研编号">
                    <el-input v-model="searchForm.hisNo" placeholder="科研编号"></el-input>
                </el-form-item>
                <el-form-item label="姓名">
                    <el-input v-model="searchForm.patientName" placeholder="姓名"></el-input>
                </el-form-item>
                <el-form-item label="联系方式">
                    <el-input v-model="searchForm.phoneNum" placeholder="联系方式"></el-input>
                </el-form-item>
                <!--                <el-form-item label="选择队列">-->
                <!--                    <el-select :clearable="true" v-model="searchForm.queueId" placeholder="选择队列">-->
                <!--                        <el-option v-for="(item,index) in queueList" :label="item.queueName"-->
                <!--                                   :value="item.id"></el-option>-->

                <!--                    </el-select>-->
                <!--                </el-form-item>-->
                <!--					<el-form-item label="年龄范围">-->
                <!--						<el-input class="age" v-model="searchForm.yearStart" placeholder="岁"></el-input>-->
                <!--						<el-input class="age" v-model="searchForm.monthStart" placeholder="月"></el-input>- -->
                <!--						<el-input class="age" v-model="searchForm.yearEnd" placeholder="岁"></el-input>-->
                <!--						<el-input class="age" v-model="searchForm.monthEnd" placeholder="月"></el-input>-->
                <!--					</el-form-item>-->
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">查询</el-button>
                </el-form-item>
            </el-form>
        </div>
        <el-table :data="table.data" border v-loading="table.loading" style="width: 100%">
            <!-- <el-table-column label="序号" align="center" prop="No" width="80">
                <template slot-scope="scope">
                    {{scope.$index+(table.current)+1}}
                </template>
            </el-table-column> -->
            <el-table-column width="150px" label="科研编号" align="center" prop="hisNo1">
                <template slot-scope="scope">
                    {{scope.row.hisNo1||'-'}}
                </template>
            </el-table-column>
            <el-table-column width="180px" label="姓名" align="center" prop="patientName">
            </el-table-column>
            <el-table-column width="200px" label="联系方式" align="center" prop="phoneNum">
            </el-table-column>
            <el-table-column width="180px" label="年龄" align="center" prop="age">
            </el-table-column>
            <el-table-column width="150px" label="性别" align="center" prop="gender2">
            </el-table-column>
            <!--            <el-table-column width="180px" label="孕周" align="center" id="pregnancyWeek" prop="pregnancyWeek">-->
            <!--            </el-table-column>-->
            <el-table-column class-name="queue" label="风险评估报告" align="center" prop="followQueueName">
                <template slot-scope="scope">
                    <template v-for="(scheme,index) in scope.row.userInfo" :key="index">
                        <el-button class="queue-btn" @click="handleToDetail(1,scheme)"
                                   type="text">{{scheme.followQueueName}}
                        </el-button>
                    </template>
                    <!-- <el-button type="text" @click="handleToDetail(scope.row)">{{scope.row.followQueueName}}</el-button> -->
                </template>
            </el-table-column>
            <!-- <el-table-column label="创建时间" align="center" prop="followQueueName">
            </el-table-column> -->
            <!-- <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                    <el-button size="mini" type="warning" @click="handleAddQueue(scope.row)">添加到系统</el-button>
                    <el-button size="mini" type="primary" @click="handleChecked(scope.row)">查看</el-button>
                </template>
            </el-table-column> -->
        </el-table>
        <div class="footer">
            <el-pagination background @current-change="handleChangePage" layout="total,prev, pager, next"
                           :total="table.total">
            </el-pagination>
        </div>

    </div>
    <div id="egg" style="display: none">
        <div style="margin: 0 auto;width: 100%">
            <div style="text-align: center;padding: 1px 0 5px 0;margin: 0px">
                <h3 style="font-weight: 700;font-size: 20px">脑卒中高危人群筛查和干预项目参与对象脑卒中风险评估报告</h3>
            </div>
            <div style="width: 100%;padding: 20px;margin: 0 auto;">

                <table border="1" style="margin: 0 auto;width: 100%;text-align: center;">
                    <tbody>
                    <tr style="height: 30px;">
                        <td width="25%" style="text-align: left;padding-left: 5px">姓名：{{dataForm.userName}}</td>
                        <td width="20%" style="text-align: left;padding-left: 5px">年龄：{{dataForm.age}}岁</td>
                        <td colspan="3" width="50%" style="text-align: left;padding-left: 5px">身份证号：{{dataForm.idCard}}</td>
                    </tr>
                    <tr style="height: 30px;">
                        <!--                    rowspan="3"-->
                        <td colspan="5" style="text-align: left;padding-left: 5px" width="100%">筛查干预单位：济源市人民医院（神经外科）</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td colspan="5" style="text-align: left;padding-left: 5px">1.本次调查结果</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td colspan="5" style="text-align: left;padding-left: 5px">检查检验结果：（备注：以下参考值范围均参考第八版《诊断学》）</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>项目</td>
                        <td>结果</td>
                        <td>单位</td>
                        <td>参考值</td>
                        <td>心电图检查</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>身高</td>
                        <td>{{dataForm.Height}}</td>
                        <td>cm</td>
                        <td>--</td>
                        <td rowspan="4">
                            {{dataForm.ncz_xdtjc.length>2?"已检查":"未检查"}}
                        </td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>体重</td>
                        <td>{{dataForm.Weight}}</td>
                        <td>kg</td>
                        <td>--</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>BMI</td>
                        <td>{{dataForm.BodyMassIndex}}</td>
                        <td>kg/m2</td>
                        <td>18.5~23.9</td>

                    </tr>
                    <tr style="height: 30px;">
                        <td>收缩压</td>
                        <td>{{dataForm.ncz_ssy}}</td>
                        <td>mmHg</td>
                        <td>90~140</td>

                    </tr>
                    <tr style="height: 30px;">
                        <td>舒张压</td>
                        <td>{{dataForm.ncz_sxy}}</td>
                        <td>mmHg</td>
                        <td>60~90</td>
                        <td>颈部血管超声检查</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>空腹血糖</td>
                        <td>{{dataForm.ncz_kfxt}}</td>
                        <td>mmol/L</td>
                        <td>3.9~6.1</td>
                        <td rowspan="8">
                            {{dataForm.ncz_jdmcc.length>2?"已检查":"未检查"}}
                        </td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>餐后2小时血糖</td>
                        <td>{{dataForm.ncz_ch2xsxt}}</td>
                        <td>mmol/L</td>
                        <td>3.9~7.8</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>糖化血红蛋白</td>
                        <td>{{dataForm.ncz_thxhdb}}</td>
                        <td>%</td>
                        <td>4%~6%</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>甘油三酯</td>
                        <td>{{dataForm.ncz_gysz}}</td>
                        <td>mmol/L</td>
                        <td>0.56~1.70</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>总胆固醇</td>
                        <td>{{dataForm.ncz_zdgc}}</td>
                        <td>mmol/L</td>
                        <td><5.2</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>低密度脂蛋白胆固醇</td>
                        <td>{{dataForm.ncz_dmdzdbdgc}}</td>
                        <td>mmol/L</td>
                        <td> ≤3.12</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>高密度脂蛋白胆固醇</td>
                        <td>{{dataForm.ncz_gmdzdbdgc}}</td>
                        <td>mmol/L</td>
                        <td>1.03~2.07</td>
                    </tr>
                    <tr style="height: 30px;">
                        <td>同型半胱氨酸</td>
                        <td>{{dataForm.ncz_txbgas}}</td>
                        <td>umol/L</td>
                        <td>5~15</td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5" style=";padding-left: 5px">主要危险因素：</td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5" style="height: 50px;padding-left: 20px">{{dataForm.ncz_zywxys}}
                        </td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5" style=";padding-left: 5px">2.脑卒中风险评级</td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5" style="height: 40px;padding-left: 10px">{{dataForm.ncz_nczfxpj}}
                        </td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5" style="height: 65px;padding-left: 10px">
                            {{dataForm.ncz_nczfxpj.indexOf("高危")>-1?"未来10年发生缺血性心血管疾病的绝对危险为2.1%，未来10年发生缺血性心血管疾病的危险是同性别，同年龄人群平均水平的1.500倍，是同性别、同年龄人群理想水平的5.250倍":""}}
                        </td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5" style=";padding-left: 5px">3.针对您的主要危险因素我们给予如下建议</td>
                        <!--                        <td rowspan="4" class="tLeft">工程介绍：低盐低盐低盐低盐低盐低盐低盐低盐低盐低盐低盐低盐低盐低盐</td>-->
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5" style=";padding-left: 5px">（1）健康指导</td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td style="padding-left: 5px">合理膳食</td>
                        <td colspan="4" style="padding-left: 5px">低盐；低脂；控制肉类食物；增加水果和蔬菜摄入量；</td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td style="padding-left: 5px">改善生活习惯</td>
                        <td colspan="4" style="padding-left: 5px">控制体重；心理平衡；戒酒</td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td style="padding-left: 5px">定期检查</td>
                        <td colspan="4" style="padding-left: 5px">血压；血糖；血脂</td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5" style="padding-left: 5px">如果您出现了以下症状--请立即拨打120!</td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5">
                            <ul>
                                <li style="list-style: disc">突然的颜面部、肢体的麻木或无力，尤其是在身体的一侧</li>
                                <li style="list-style: disc">突然说不出物体的名称，说话或理解困难</li>
                                <li style="list-style: disc">突然出现嗜睡状态，即患者昏昏沉沉，总想睡觉</li>
                                <li style="list-style: disc">突然行走困难，头晕，伴有恶心、呕吐，肢体失去平衡或不协调</li>
                                <li style="list-style: disc">突然单眼或双眼视物不清</li>
                                <li style="list-style: disc">突然的不明原因的没有经历过的严重头痛，可有恶心呕吐</li>
                            </ul>
                        </td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5" style="padding-left: 5px">(2)用药、手术及其他建议(250字符以内)</td>
                    </tr>
                    <tr style="height: 30px;text-align: left">
                        <td colspan="5" style="padding-left: 5px">低盐低脂糖尿病饮食;监测血压，建议继续规律口服降压药物;限酒;适当运动，减轻体重;监测血糖，建议糖尿病专科明确糖尿病诊断;定期市人民医院门诊2楼255室脑卒中筛查与干预门诊随诊，不适随诊。</td>
                    </tr>
                    </tbody>
                </table>

            </div>
        </div>
    </div>
    <el-button class="but" style="display:none;position: fixed;bottom: 50px;right: 150px;width: 100px;height: 40px"
               @click="printHandle">打印
    </el-button>
    <!--    <input type="button" class="but" value="打印" onclick="printHandle()" style="display:none;position: absolute;bottom: 50px;right: 150px">-->
</div>

</body>
<script type="text/javascript">
    // require(['jquery', 'fu/app/dataCenter/dataCenter'], function ($, $dataCenter) {
    // 	$dataCenter.init()
    // });


    require(['bbcare', 'jquery'], function ($bb, $) {
        var URL = $bb.baseUrl("followup")

        var vm = new Vue({
            el: '#root',
            data: {
                //队列
                queueList: [],
                searchForm: {
                    queueId: '',
                    phoneNum: '',
                    patientName: '',
                    hisNo: '',
                    yearStart: '',
                    monthStart: '',
                    yearEnd: '',
                    monthEnd: '',
                    num: 1,
                },
                dataForm: {
                    Height: "",
                    Weight: "",
                    BodyMassIndex: "",
                    ncz_ssy: "",
                    ncz_sxy: "",
                    ncz_kfxt: "",
                    ncz_ch2xsxt: "",
                    ncz_thxhdb: "",
                    ncz_gysz: "",
                    ncz_zdgc: "",
                    ncz_dmdzdbdgc: "",
                    ncz_gmdzdbdgc: "",
                    ncz_txbgas: "",
                    ncz_nczfxpj: "",
                    ncz_zywxys: "",
                    ncz_jdmcc: "",
                    ncz_xdtjc: "",
                    idCard: '',
                    age: '',
                    userName: '',
                },

                table: {
                    current: 1,
                    size: 10,
                    total: 0,
                    data: [],
                    loading: false,
                },
                biaoge: true
            },
            created: function () {
                this.getTableData()
                this.ajaxQueue()
            },
            methods: {

                printHandle() {
                    let body_box = window.document.body.innerHTML
                    let print_box = document.querySelector('#egg').innerHTML
                    // 打印前
                    window.onbeforeprint = () => {
                        console.log('开始打印')
                        window.document.body.innerHTML = print_box
                        // document.getElementsByTagName('body')[0].style.zoom = 0.92;
                    }
                    // 打印后
                    window.onafterprint = () => {
                        console.log('结束打印')
                        window.document.body.innerHTML = body_box // vue使用此方法第二次点按钮会失效
                        location.reload() // 可使用刷新解决vue按钮失效问题
                    }
                    // 打印
                    window.print()

                },


                getParams(searchForm) {
                    let param = {
                        // args: {
                        // 	start: this.table.current,
                        // 	length: this.table.size
                        // },
                        page: this.table.current,
                        rows: this.table.size,
                        flag: 2,
                        userStatus: 0
                    }
                    if (searchForm.hisNo) {
                        param.hisNo = searchForm.hisNo
                    }
                    if (searchForm.patientName) {
                        param.patientName = searchForm.patientName
                    }
                    if (searchForm.phoneNum) {
                        param.phoneNum = searchForm.phoneNum
                    }
                    // if (searchForm.queueId) {
                    // param.queueId = "duiLie_001_naocuzhong"
                    param.queueId = "duiLie_naocuzhong"
                    // }
                    if (searchForm.yearStart && searchForm.yearEnd) {
                        param.ageFrom = parseInt(searchForm.yearStart * 12)
                        param.ageTo = parseInt(searchForm.yearEnd * 12)
                    }
                    if (searchForm.monthStart && searchForm.monthEnd) {
                        param.ageFrom = parseInt(searchForm.monthStart)
                        param.ageTo = parseInt(searchForm.monthEnd)
                    }
                    if (searchForm.monthStart && searchForm.yearEnd) {
                        param.ageFrom = parseInt(searchForm.monthStart)
                        param.ageTo = parseInt(searchForm.yearEnd * 12)
                    }
                    if (searchForm.yearStart && searchForm.monthEnd) {
                        param.ageFrom = parseInt(searchForm.yearStart * 12)
                        param.ageTo = parseInt(searchForm.monthEnd)
                    }
                    if (searchForm.yearStart && searchForm.yearEnd && searchForm.monthEnd) {
                        param.ageFrom = parseInt(searchForm.yearStart * 12)
                        param.ageTo = parseInt(searchForm.yearEnd * 12) + parseInt(searchForm.monthEnd)
                    }
                    if (searchForm.monthStart && searchForm.yearEnd && searchForm.monthEnd) {
                        param.ageFrom = parseInt(searchForm.monthStart)
                        param.ageTo = parseInt(searchForm.yearEnd * 12) + parseInt(searchForm.monthEnd)
                    }
                    if (searchForm.yearStart && searchForm.yearEnd && searchForm.monthStart && searchForm.monthEnd) {
                        param.ageFrom = parseInt(searchForm.yearStart * 12) + parseInt(searchForm.monthStart)
                        param.ageTo = parseInt(searchForm.yearEnd * 12) + parseInt(searchForm.monthEnd)
                    }
                    return param
                },
                // 查询队列
                ajaxQueue() {
                    let that = this
                    $bb.ajax({
                        url: URL + "followup/service/queue/followQueueListQuery",
                        success: function (data) {
                            if (data.success) {
                                that.queueList = data.data.rows
                            }
                        }
                    })
                },

                // 查询数据
                getTableData() {
                    let that = this
                    that.table.loading = true
                    console.log(that.getParams(that.searchForm))
                    $bb.ajax({
                        url: URL + 'followup/service/patient/queryPatientListDataCenter',
                        data: JSON.stringify({
                            data: that.getParams(that.searchForm)
                        }),
                        success: function (res) {
                            const datas = res.rows
                            that.table.total = res.total
                            that.table.data = datas
                            that.table.loading = false
                        }
                    })
                },


                onSubmit() {
                    this.table.current = 1
                    this.getTableData()
                },


                handleChangePage(page) {
                    // this.table.current = (page - 1) * this.table.size
                    this.table.current = page
                    this.getTableData()
                },

                handleToDetail: function (row, scheme) {
                    let that = this
                    let params = {
                        followQueueId: scheme.followQueueId,
                        // imgSrc: row.gender == 'N' || row.gender == 1 ? 'page/followup/imgs/comm/boy.png' : 'page/followup/imgs/comm/girl.png',
                        // patientId: row.patientId,
                        // patientName: row.patientName,
                        patientSchemeId: scheme.patientSchemeId,
                        // queuename: scheme.followQueueName,
                    }
                    // $bb.openPage("outPatient", params)
                    $bb.ajax({
                        url: URL + "followup/service/patient/patientTaskListQuery",
                        data: JSON.stringify({
                            data: params
                        }),
                        success: function (data) {
                            let datas = data.data.rows
                            const param = {
                                followQueueId: params.followQueueId,
                                ptTaskId: datas[datas.length - row]["taskId"]
                            }
                            $bb.ajax({
                                url: URL + "followup/service/patient/patientTaskContentDataQuery",
                                data: JSON.stringify({
                                    data: param
                                }),
                                success: function (res) {

                                    // if (row.data)
                                    if (datas[datas.length - row]["taskName"] == "第一次随访") {

                                        if (res.data.values["Pub13x00007"] != null && res.data.values["Pub13x00007"] != "") {
                                            $("#roots").css("display", "none")
                                            $("#rootss").css("display", "none")
                                            $("#egg").css("display", "block")
                                            $(".but").css("display", "block")

                                            const data = res.data
                                            const dataForm = {...data.patient, ...data.values}

                                            that.dataForm = dataForm
                                            that.dataForm["age"] = that.showAge(dataForm.expectedDay)
                                        } else {
                                            that.$message({
                                                message: '暂未进行"8+2"脑卒中量表评测',
                                                type: 'warning'
                                            });
                                        }

                                    } else {
                                        if (res.data.values["Pub13x00007"] != null && res.data.values["Pub13x00007"] != "") {
                                            $("#roots").css("display", "none")
                                            $("#rootss").css("display", "none")
                                            $("#egg").css("display", "block")
                                            $(".but").css("display", "block")
                                            const data = res.data
                                            const dataForm = {...data.patient, ...data.values}

                                            that.dataForm = dataForm
                                            that.dataForm["age"] = that.showAge(dataForm.expectedDay)
                                        } else {
                                            that.handleToDetail(2, scheme)
                                        }

                                    }

                                }
                            })
                        }
                    });
                },


                showAge(value) {

                    // 指定日期

                    let birthdays = new Date(value.replace(/-/g, "/"))

                    // 当前系统日期

                    let d = new Date();

                    let age = d.getFullYear() - birthdays.getFullYear() - (d.getMonth() <
                    birthdays.getMonth() || (d.getMonth() == birthdays.getMonth() &&
                        d.getDate() < birthdays.getDate()) ? 1 : 0);

                    return age

                }
            }
        })
    })
</script>
